In addition to the general options in Table 2-2, each driver has options that you typically won't use. These options primarily aid compiler development work. For information about nonstandard driver options, consult the appropriate driver reference page. Click the word cc to view the cc(1) and CC(1) reference pages.
You can use the compiler system to generate profiled programs that, when executed, provide operational statistics. To perform this procedure, use the -p compiler option (for pc sampling information) and the prof command (for profiles of basic block counts). Refer to Chapter 4, "Using the Performance Tools," for details.
Option | Purpose |
---|---|
-32 | Generates a 32-bit object. |
-n32 | Generates an n32-bit object. |
-64 | Generates a 64-bit object. This is the default. |
-ansi | Strict ANSI/ISO C compilation mode. Preprocessing adds only standard predefined symbols to the name space, and standard include files declare only standard symbols. |
-c | Prevents the linker from linking your program after code generation. This option forces the driver to produce a .o file after the back-end phase, and prevents the driver from producing an executable file. |
-C | Used with the -P or -E option. Prevents the macro preprocessor from stripping comments. Use this option when you suspect the preprocessor is not producing the intended code and you want to examine the code with its comments. For C and C++ compiles only. |
-cord | Runs the procedure rearranger, cord(1) on the resulting file after linking. Rearranging improves the paging and caching performance of the program's text. The output of cord is placed in a.out, by default, or a file specified by the -o option. If you don't specify -feedback, then outfile.fb is used as the default. |
-cckr | K&R/Version7 C compatibility compilation mode. Preprocessing may add more predefined symbols to the name space than in -ansi mode. Compilation adheres to the K&R language semantics. |
-Dname[=def] | Defines a macro name as if you had specified a #define in your program. If you do not specify a definition with =def, name is set to 1. |
-E | Runs only the macro preprocessor and sends results to the standard output. To retain comments, use the -C option as well. Use -E when you suspect the preprocessor is not producing the intended code. |
-elspec filename | Specifies an ELF layout specification file (specifies the layout of object files, programs, and shared objects). See elspec(5) for details. |
-feedback | Use with the -cord option to specify feedback file(s). You can produce this file by using prof with its -feedback option from an execution of the instrumented program produced by pixie(1). Specify multiple feedback files with multiple -feedback options. |
-fullwarn | Checks code and produces additional warnings that are normally suppressed. This option is recommended for all compiles during software development. You can turn off warnings selectively by using the -woff option. |
-g[num] | Produces debugging information. The default is -g0: do not produce debugging information. |
-G[num] | Specifies the maximum size, in bytes, of a data item that is accessed from the global pointer. The default is -G8. |
-help | Lists the available compiler options. |
-Idirname | Adds dirname to the list of directories to be searched for specified header files. These directories are always searched before the default directory, /usr/include. |
-KPIC | Generates position-independent code. This is the default and is required for programs linking with dynamic shared objects. Specify -non_shared if you don't want to generate PIC code. |
-mips1 | Generates code using the instruction set of the MIPS R2000/R3000 RISC architecture. This option implies -32. |
-mips2 | Generates code using the MIPS II instruction set (MIPS I + R4000 specific extensions). Note that code compiled with -mips2 does not run on R2000/R3000-based machines. This option implies -32. |
-mips3 | Generates code using the full MIPS R4000 instruction set, including 64-bit code. |
-mips4 | Generates code using the MIPS R8000 instruction set. |
-nocpp | Suppresses running of the macro preprocessor on the source files prior to processing. |
-non_shared | Turns off the default option, -KPIC, to produce non-shared code. This code can be linked to only a few standard libraries (such as libc.a and libm.a) that are provided in non-shared format in the directory /usr/lib/nonshared. You should use this option only when building device drivers. |
-nostdinc | Suppresses searching of /usr/include for the specified header files. |
-o filename | Names the result of the compilation filename. If an executable is being generated, it is named filename rather than the default name, a.out. |
-Onum | Specifies optimization options. -O0 turns off optimizations. -O1 turns on local optimizations that can be done quickly. -O2 (-O) turns on global optimizations. This is the default. -O3 turns on all optimizations. For more information, see Chapter 5, "Optimizing Program Performance." |
-OPT:options | Controls optimization options. For more information, see Chapter 5, "Optimizing Program Performance." |
-p | Sets up for profiling by periodically sampling the value of the program counter (only effects the loading). |
-P | Runs only the macro preprocessor on the files and puts the result of each file in a .i file. Specify both -P and -C to retain comments. |
-pch | Enables the precompiled header processing; fec/fecc searches for a qualifying PCH file to read in and/or creates one for use on a subsequent compilation. |
-S | Similar to -c, except that it produces assembly code in a .s file instead of object code in a .o file. -S provides information about the code and comments about such things as software pipelining, the loops it works on, and the results. |
-show | Lists compiler phases as they are executed. Use this option to see the default options for each compiler phase along with the options you've specified. |
-SWP:options | Controls software pipelining of inner loops. For more information, see Chapter 5, "Optimizing Program Performance." |
-TARG:options | Controls the target architecture and machine for which code is generated. For more information, see Chapter 5, "Optimizing Program Performance." |
-TENV:options | Controls the target environment assumed by the compiler. For more information, see Chapter 5, "Optimizing Program Performance." |
-Uname | Overrides a definition of the macro name that you specified with the -D option, or that is defined automatically by the driver. Note that this option does not override a macro definition in a source file, only on the command line. |
-woff n | Suppresses ANSI/ISO warning message number n. Suppress multiple warning numbers by using a comma-separated list (-woff n1,n2...), a range of warning numbers by using a hyphen-separated list (-woff n1-n5), or any combination thereof. You can suppress all warning messages via -woff all. |
-xansi | Compilation follows an extended ANSI/ISO C language semantics, which is more lenient in terms of the forms of expressions it allows. Preprocessing combines predefined macros. This is the default C compilation mode. |
-xgot | Compiles using a 32-bit offset in the Global Symbol Table (GOT). By default, addresses are loaded out of the GOT using a 16-bit offset from a context pointer. The default size of the GOT thus is limited to 64K bytes, or about 8K worth of symbols, 16K for 32-bit compiled objects. This can sometimes result in a "GOT overflow" message. Use of the -xgot option allows the GOT to contain up to 1G of entries; however, the resulting executable is somewhat larger and slower. -xgot is a synonym for -TENV:large_GOT (for information on this option, see "Controlling the Target Environment"). |
Note: To use 4.3 BSD extensions in C, compile using the -xansi or the -D__EXTENSIONS__ option on the command line. For example:cc prog.c -ansi -prototypes -fullwarn -lm -D__EXTENSIONS__